package com.chat.api.common.exception;
/**
 * 与ApiException异常作用相同，但不会给前端返回400，避免出发前端弹窗拦截器
 * **/
public class ParamException extends RuntimeException {
	private static final long serialVersionUID = -8880499705725759835L;

	private Integer code;

	/** 异常消息  */
    private String errorMessage;

    /** 跳转路径 */
    private String errorUrl;

    public ParamException(Integer code, String errorMessage, String errorUrl) {
    	super(errorMessage);
        this.code = code;
        this.errorMessage = errorMessage;
        this.setErrorUrl(errorUrl);
    }

    public ParamException(String errorMessage) {
    	this(CoreExceptionEnum.E_INVALID_PARAM.getCode(), errorMessage, "");
    }

    public ParamException(Integer code, String errorMessage) {
    	super(errorMessage);
        this.code = code;
        this.errorMessage = errorMessage;
        this.errorUrl="";
    }

    public ParamException(AbstractBaseExceptionEnum exception, String errorUrl) {
    	super(exception.getMessage());
        this.code = exception.getCode();
        this.errorMessage = exception.getMessage();
        this.errorUrl=errorUrl;
    }

    public ParamException(AbstractBaseExceptionEnum exception) {
    	super(exception.getMessage());
        this.code = exception.getCode();
        this.errorMessage = exception.getMessage();
        this.errorUrl="";
    }

    public ParamException() {
		super();
	}

	public ParamException(Throwable ex) {
		super(ex);
	}

	public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

	public String getErrorUrl() {
		return errorUrl;
	}

	public void setErrorUrl(String errorUrl) {
		this.errorUrl = errorUrl;
	}
}
